debug = true;

if (debug) {
  $( document ).ajaxError(function( event, jqxhr, settings, thrownError ) {
    $( 'body' ).append(jqxhr.responseText);
  });
}

$.ajaxSetup({
  headers : { 'X-CSRF-Token' : $('meta[name=_token]').attr('content') }
});


var util = (function () {
  return {
    inheritFunctions : function (instance, functions) {
      var x,
          prop;

      for (x in functions) {
        prop = functions[x];
        if (typeof(prop) === 'function') {
          instance[x] = prop;
        }
      }

      return instance;
    },
    inheritProperties : function (instance, functions) {
      var x,
          prop;

      for (x in functions) {
        prop = functions[x];
        if (typeof(prop) !== 'function') {
          instance[x] = prop;
        }
      }

      return instance;
    },
    makeDataObject : function (setOfNames, index) {
      var obj = {},
          i;

      for (i=0; i<setOfNames.length; i++) {
        console.log(i);
        obj[setOfNames[i]] = $('.info-' + index + ' [name="' +
                               setOfNames[i] + '"]').val();
      }

      return obj;
    }
  };
})();

